package cloud.lysky.game.gamesampe.component;

import com.almasb.fxgl.entity.component.Component;
import io.swagger.v3.oas.annotations.media.Schema;
import javafx.beans.property.*;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Schema(description = "统计栏组件")
public class StatsComponent extends Component {
    @Schema(description = "名称")
    private final StringProperty name = new SimpleStringProperty();

    @Schema(description = "攻击力")
    private final IntegerProperty ATK = new SimpleIntegerProperty();

    @Schema(description = "防御力")
    private final IntegerProperty defense = new SimpleIntegerProperty();

    @Schema(description = "暴击率")
    private final DoubleProperty criticalHitRate = new SimpleDoubleProperty();

    @Schema(description = "暴击效果")
    private final DoubleProperty criticalBonus = new SimpleDoubleProperty();;


    public int getATK() {
        return ATK.get();
    }

    public IntegerProperty ATKProperty() {
        return ATK;
    }

    public IntegerProperty defenseProperty() {
        return defense;
    }

    public StatsComponent(String name, int ATK, int defense, double criticalHitRate, double criticalBonus) {
        this.name.set(name);
        this.ATK.set(ATK);
        this.defense.set(defense);
        this.criticalHitRate.set(criticalHitRate);
        this.criticalBonus.set(criticalBonus);
    }
    public String getName() {
        return name.get();
    }
    public int getAtk() {
        return ATK.get();
    }
    public int getDefense() {
        return defense.get();
    }

    public double getCriticalHitRate() {
        return criticalHitRate.get();
    }

    public String getCriticalHitRateStr() {
        double rate = criticalHitRate.get();
        return new BigDecimal(rate).multiply(new BigDecimal(100)).setScale(0, RoundingMode.FLOOR) + "%";
    }

    public double getCriticalBonus() {
        return criticalBonus.get();
    }

    public String getCriticalBonusStr() {
        double bonus = criticalBonus.get();
        return new BigDecimal(bonus).multiply(new BigDecimal(100)).setScale(0, RoundingMode.FLOOR) + "%" ;
    }

    public DoubleProperty criticalHitRateProperty() {
        return criticalHitRate;
    }

    public DoubleProperty criticalBonusProperty() {
        return criticalBonus;
    }

    public StringProperty nameProperty() {
        return name;
    }
    public IntegerProperty atkProperty() {
        return ATK;
    }
    public IntegerProperty defProperty() {
        return defense;
    }
}
